home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 61 / Quick PC 61.iso / I386 / SASETUP.MSI / F77690_Single_Log_Details.asp < prev    next >
Encoding:
Text File  |  2003-02-21  |  11.3 KB  |  272 lines

  1. <%@ Language=VBScript   %>
  2. <%  Option Explicit     %>
  3. <%
  4.     '-------------------------------------------------------------------------------------
  5.     ' Single_Log_Details.asp:  provides links for clearing and downloading the logs
  6.     ' Copyright (c) Microsoft Corporation.  All rights reserved. 
  7.     '-------------------------------------------------------------------------------------
  8. %>
  9.     <meta http-equiv="Content-Type" content="text/html; charset=<%=GetCharSet()%>">
  10.     <!-- #include virtual="/admin/inc_framework.asp" --> 
  11.     <!-- #include file="loc_Log.asp" -->
  12.     <!-- #include file="inc_Log.asp" -->
  13. <%
  14.     '-------------------------------------------------------------------------
  15.     ' Global Variables
  16.     '-------------------------------------------------------------------------
  17.     Dim rc                  'Return value for CreatePage
  18.     Dim page                'Variable that receives the output page object when
  19.                             'creating a page 
  20.     Dim G_strLogFilePath    'FilePath
  21.     Dim G_strLogFileName    'FileName
  22.     Dim G_PageTitle         'To get the title accordingly 
  23.     
  24.     Const CONST_BUTTON_DISABLE = "disabled"  ' button status - doesnot need localization
  25.     '-------------------------------------------------------------------------
  26.     ' Form Variables
  27.     '-------------------------------------------------------------------------
  28.     Dim F_strevent_title    'To get the title from previous page
  29.     Dim F_strPKeyValue      'Key val consists of filename
  30.  
  31.     'this code is placed here to get the page title 
  32.     G_PageTitle = GetTitle(Request.QueryString("logtitle"))
  33.     
  34.     Call SA_CreatePage(G_PageTitle ,"",PT_AREA, page )
  35.     Call SA_ShowPage( page )
  36.  
  37.     '---------------------------------------------------------------------
  38.     ' Function name:    OnInitPage
  39.     ' Description:      Called to signal first time processing for this page. 
  40.     ' Input Variables:  PageIn and EventArg
  41.     ' Output Variables: None
  42.     ' Return Values:    TRUE to indicate initialization was successful. FALSE to indicate
  43.     '                   errors. Returning FALSE will cause the page to be abandoned.
  44.     ' Global Variables: None
  45.     ' Called to signal first time processing for this page. 
  46.     '---------------------------------------------------------------------
  47.     Public Function OnInitPage(ByRef PageIn, ByRef EventArg)
  48.         OnInitPage = TRUE
  49.     End Function
  50.     
  51.     '---------------------------------------------------------------------
  52.     ' Function name:    OnServeAreaPage
  53.     ' Description:      Called when the page needs to be served. 
  54.     ' Input Variables:  PageIn, EventArg
  55.     ' Output Variables: None
  56.     ' Return Values:    TRUE to indicate no problems occured. FALSE to indicate errors.
  57.     '                   Returning FALSE will cause the page to be abandoned.
  58.     ' Global Variables: None
  59.     'Called when the page needs to be served. Use this method to serve content.
  60.     '---------------------------------------------------------------------
  61.     Public Function OnServeAreaPage(ByRef PageIn, ByRef EventArg) 
  62.         On Error Resume Next        
  63.         Err.Clear
  64.         
  65.  
  66.         Dim strPassValue    ' the value to be passed through the query string
  67.         Dim strButtonStatus ' the status of the button ( ""<empty> or Disabled)
  68.         Dim strViewUrl      ' url to be passed to the iframe
  69.         Dim blnFileExists
  70.         
  71.         Dim objFso        ' the file system object
  72.         Dim strDownloadUrl
  73.         
  74.         'frame work variables
  75.         Dim x
  76.         Dim itemCount
  77.         Dim itemKey
  78.         
  79.         Call ServeCommonJavaScript()
  80.         
  81.         itemCount = OTS_GetTableSelectionCount("")
  82.         F_strevent_title  = Request.QueryString("logtitle")
  83.         
  84.         If instr(1,F_strevent_title,"NFS",1) = 0 then       
  85.             For x = 1 to itemCount
  86.                 If ( OTS_GetTableSelection("", x, itemKey) ) Then
  87.                     F_strPKeyValue = itemKey
  88.                     Call SA_TraceOut("Single_Log_Details.asp", "PKey value: " + F_strPKeyValue)
  89.                 End If
  90.             Next    
  91.         End If
  92.         
  93.         blnFileExists = True
  94.         
  95.         ' initially the button is enabled
  96.         strButtonStatus = ""
  97.         
  98.         'Getting the FilePath of the selected log file
  99.         G_strLogFilePath=GetPath(F_strevent_title)
  100.  
  101.         'Checking for the pkey value
  102.         If F_strPKeyValue <> "" Then        
  103.             'Getting the filename from the earliear form
  104.             G_strLogFileName=F_strPKeyValue
  105.         Else
  106.         
  107.             'check for null if so go for alternative
  108.             If G_strLogFileName = "" Then
  109.                 'Getting the FileName through  FSO
  110.                 G_strLogFileName=getFileNameInFolder(G_strLogFilePath)
  111.             End IF
  112.                 
  113.         End IF  
  114.          
  115.          
  116.         If ( (Len(Trim(G_strLogFilePath)) = 0) OR (Len(Trim(G_strLogFileName)) <=0) _
  117.             OR (Err.number <> 0) ) Then
  118.             ' disable the buttons
  119.             strButtonStatus = CONST_BUTTON_DISABLE
  120.             blnFileExists = False
  121.             strPassValue = "" ' set the value to be passed to query string to null
  122.             Err.Clear 
  123.         Else    
  124.             
  125.             ' create the FSO
  126.             Set objFso = CreateObject("Scripting.FileSystemObject")
  127.             If Err.number <> 0 Then
  128.                 WriteFileData = L_FSO_OBJECTCREATE_ERRORMESSAGE & "( "& Hex(Err.number)  & " )"
  129.                 Err.Clear 
  130.                 Exit Function
  131.             End If
  132.  
  133.             'checking for the file existence
  134.             If  NOT (objFso.FileExists(G_strLogFilePath & "\" & G_strLogFileName)) Then
  135.                 'make blnFileExists false if file does not exists
  136.                 blnFileExists = False
  137.                 strButtonStatus = CONST_BUTTON_DISABLE
  138.             End IF
  139.             
  140.             'Name of the log along with the path
  141.             strPassValue=Server.URLEncode(G_strLogFilePath & "\" & G_strLogFileName) 
  142.  
  143.             'Take care of escape chars
  144.             G_strLogFilePath=Server.URLEncode(G_strLogFilePath)
  145.         End If
  146.  
  147.              strViewUrl = "log_view.asp?FileToView=" & strPassValue & "&" & _
  148.                                         SAI_FLD_PAGEKEY & "=" & SAI_GetPageKey()
  149. %>  
  150.         <table width=95% border=0 cellspacing=0 cellpadding=0 >
  151.             <tr>
  152.                 <td colspan=4 height=30 class="TasksBody"> </td>
  153.             </tr>
  154.             <tr>
  155.                 <td width="20px" class="TasksBody"> </td>
  156.                 <td width="600px" class="TasksBody">
  157.                     <iframe width="100%" height="275px" src="<%=Server.HTMLEncode(SA_EscapeQuotes(strViewUrl))%>" frameborder="yes" >
  158.                     </iframe> 
  159.                 </td>
  160.                 <td class="TasksBody" width="20px"> </td>
  161.                 <td VALIGN = TOP class="TasksBody"> 
  162. <%      
  163.                         If blnFileExists = False then 
  164.                             Call SA_ServeOnClickButton(SA_EscapeQuotes(L_DOWNLOAD_TEXT), "",_
  165.                                "",_
  166.                                 90,"", CONST_BUTTON_DISABLE )   
  167.                         Response.write "<BR>"           
  168.                         Else 
  169.  
  170.                         strDownloadUrl = m_VirtualRoot & "logs/Text_Log_download.asp?FilePath=" & _
  171.                                          strPassValue & "&" & SAI_FLD_PAGEKEY & "=" & SAI_GetPageKey()
  172.                 %>
  173.                         <iframe name=IFDownload src='<%=Server.HTMLEncode(SA_EscapeQuotes(strDownloadUrl))%>' height="36px" frameborder="0" scrolling="no">
  174.                         </iframe>
  175.                 <%          
  176.                         End If  %>  
  177.                         <BR><BR>
  178.                 <%
  179.                         Call SA_ServeOpenPageButton( PT_PROPERTY, _
  180.                                                     "logs/Text_Log_clear.asp?FilePath="& strPassValue & _
  181.                                                     "&tab1=" & GetTab1() & "&tab2=" & GetTab2() & "&" & _
  182.                                                     SAI_FLD_PAGEKEY & "=" & SAI_GetPageKey(),_
  183.                                                     Request.QueryString("URL"),_
  184.                                                     Server.HTMLEncode(SA_EscapeQuotes(L_CLEAR_TEXT)),_
  185.                                                     SA_EscapeQuotes(L_CLEAR_TEXT),_
  186.                                                     "",_
  187.                                                     90, "", strButtonStatus)                    
  188.                 %>          
  189.                 </td>
  190.             </tr>
  191.         </table>
  192.         
  193.     <%
  194.         
  195.         OnServeAreaPage=TRUE
  196.     End Function
  197.     
  198.     '-------------------------------------------------------------------------
  199.     'Function name:     getFileNameInFolder
  200.     'Description:       Serves in Getting the file name present in the given folder
  201.     'Input Variables:   strFilePath
  202.     'Output Variables:  String
  203.     'Returns:           the file name or empty string
  204.     'This returns the First file name in the given folder containing set of files.
  205.     'In case ANY error occurs, this returns empty string
  206.     '-------------------------------------------------------------------------
  207.     Function getFileNameInFolder(strFilePath)
  208.         Err.Clear 
  209.         On Error Resume Next
  210.  
  211.         Dim objFso          ' the file system object
  212.         Dim objFolder       ' the folder object, where to look for the file ?
  213.         Dim objFiles        ' the files in the folder
  214.         Dim objFile         ' the required file
  215.         Dim strFileName     ' the file name to be returned
  216.  
  217.         Set objFso = CreateObject("Scripting.FileSystemObject")
  218.         
  219.         If Err.number <> 0 Then
  220.             getFileNameInFolder = ""
  221.             Exit Function
  222.         End If
  223.         
  224.         'Checking for the folder existence
  225.         IF NOT objFso.FolderExists(strFilePath) Then
  226.             getFileNameInFolder = ""
  227.             Exit Function
  228.         End IF
  229.         
  230.         Set objFiles = objFso.GetFolder(strFilePath).Files
  231.         
  232.         If objFiles.Count <=0 Then
  233.             'No files available
  234.             getFileNameInFolder = ""
  235.             Exit Function
  236.         End If
  237.  
  238.         For each objFile in objFiles
  239.             strFileName = objFile.name
  240.             Exit For ' just pick the first file name
  241.         Next
  242.  
  243.         getFileNameInFolder = strFileName
  244.  
  245.         ' clean up
  246.         Set objFiles  = Nothing
  247.         Set objFolder = Nothing
  248.         Set objFSO    = Nothing
  249.  
  250.     End Function
  251.     
  252.     '-------------------------------------------------------------------------
  253.     'Function:              ServeCommonJavaScript
  254.     'Description:           Serves in initialiging the values,setting the form
  255.     '                       data and validating the form values
  256.     'Input Variables:       None
  257.     'Output Variables:      None
  258.     'Returns:               True/False
  259.     'Global Variables:      None
  260.     '-------------------------------------------------------------------------
  261.     Function ServeCommonJavaScript()
  262.     %>
  263.     <script language="JavaScript">
  264.         function Init()
  265.         {
  266.             return true;
  267.         }
  268.     </script>
  269.     <%End Function  
  270.  
  271. %>
  272.